﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wormhole.Engine.Player
{
	/// <author>Rodney McKay</author>
	/// <date>28 March 2008</date>
	/// <summary>
	/// This class is used to track the player score.
	/// </summary>
	public class Score
	{
		#region Delegates
		/// <summary>
		/// The delegate for the score changed event.
		/// </summary>
		public delegate void ScoreChangedDelegate();
		#endregion

		#region Events
		/// <summary>
		/// The event that fires when the score is changed.
		/// </summary>
		public event ScoreChangedDelegate ScoreChanged;
		#endregion

		#region Properties

		#region Glyph Score
		private int _glyphScore;
		/// <summary>The glyph score.</summary>
		public int GlyphScore 
		{
			get
			{
				return this._glyphScore;
			}

			set
			{
				if (this._glyphScore != value)
				{
					this._glyphScore = value;
					this.OnScoreChanged();
				}
			}
		}
		#endregion

		#region Glyph Total
		private int _glyphTotal;
		/// <summary>The maximum glyph score - when this score is reached the player wins.</summary>
		public int GlyphTotal 
		{
			get
			{
				return this._glyphTotal;
			}

			set
			{
				if (this._glyphTotal != value)
				{
					this._glyphTotal = value;
					this.OnScoreChanged();
				}
			}
		}
		#endregion

		#region Experience Score
		private int _experienceScore;
		/// <summary>The experience score.</summary>
		public int ExperienceScore 
		{
			get
			{
				return this._experienceScore;
			}

			set
			{
				if (this._experienceScore != value)
				{
					this._experienceScore = value;
					this.OnScoreChanged();
				}
			}
		}
		#endregion

		#region Villian Score
		private int _villianScore;
		/// <summary>The villian score.</summary>
		public int VillianScore 
		{
			get
			{
				return this._villianScore;
			}

			set
			{
				if (this._villianScore != value)
				{
					this._villianScore = value;
					this.OnScoreChanged();
				}
			}
		}
		#endregion

		#region Victory Total
		private int _victoryTotal;
		/// <summary>
		/// The victory total, when villian score or experience is equal to this, the player wins.
		/// </summary>
		public int VictoryTotal 
		{
			get
			{
				return this._victoryTotal;
			}

			set
			{
				if (this._victoryTotal != value)
				{
					this._victoryTotal = value;
					this.OnScoreChanged();
				}
			}
		}
		#endregion

		#endregion

		#region Constructor
		/// <summary>
		/// Initialize a default instance of the class.
		/// </summary>
		public Score()
		{
			this.GlyphScore = 0;
			this.GlyphTotal = 7;
			this.ExperienceScore = 0;
			this.VillianScore = 0;
			this.VictoryTotal = 0;
		}
		#endregion

		#region On Score Changed
		/// <summary>
		/// Fire the score changed event.
		/// </summary>
		protected void OnScoreChanged()
		{
			if (this.ScoreChanged != null)
				this.ScoreChanged();
		}
		#endregion
	}
}
